home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_pas / sk210f.zip / TESTCMDL.PAS < prev    next >
Pascal/Delphi Source File  |  1992-05-13  |  3KB  |  130 lines

  1. {$I SHDEFINE.INC}
  2.  
  3. {$IFDEF Gen87}
  4.   {$N+,E+}
  5. {$ELSE}
  6.   {$N-}
  7. {$ENDIF}
  8.  
  9. {$IFNDEF EmulationOK}
  10.   {$E-}
  11. {$ENDIF}
  12.  
  13. program TestCmdL;
  14. {
  15.                        To test the ShCmdLin unit
  16.  
  17.                   Copyright 1991 Madison & Associates
  18.                           All Rights Reserved
  19.  
  20.          This program source file and the associated executable
  21.          file may be  used and distributed  only in  accordance
  22.          with the  provisions  described  on  the title page of
  23.                   the accompanying documentation file
  24.                               SKYHAWK.DOC
  25. }
  26.  
  27. uses
  28. {$IFDEF OverlaysOK}
  29.   OverCmdl,
  30.   Overlay,
  31. {$ENDIF}
  32.  
  33.   TpDos,
  34.   TpCrt,
  35.   ShCmdLin,
  36.   ShList,
  37.   ShUtilPk;
  38.  
  39. {$IFDEF OverlaysOK}
  40.   {$F+}
  41.   {$O SHCMDLIN.TPU}
  42.   {$O SHLIST.TPU}
  43.   {$O TPDOS.TPU}
  44. {$ENDIF}
  45.  
  46.  
  47. const
  48.   VT  : array[VtStr..VtInt] of string = ('String ',
  49.                                          'Real   ',
  50.                                          'Integer');
  51.  
  52. var
  53.   S1      : string;
  54.   Y       : SwRec;
  55.   Err     : Integer;
  56.   OT      : text;
  57.  
  58. procedure AnyKey;
  59.   begin
  60.     if HandleIsConsole(1) then begin
  61.       Write('Any key to continue...');
  62.       if ReadKey = #0 then ;
  63.       WriteLn;
  64.       end;
  65.     end;
  66.  
  67. function ValStr : string;
  68.   var
  69.     S2  : string;
  70.   begin
  71.     case Y.SwVal of
  72.       VtStr   : ValStr := Y.StrVal;
  73.       VtReal  : begin
  74.                   Str(Y.RealVal, S2);
  75.                   ValStr := S2;
  76.                   end;
  77.       VtInt   : begin
  78.                   Str(Y.IntVal, S2);
  79.                   ValStr := S2;
  80.                   end;
  81.       end;
  82.     end; {ValStr}
  83.  
  84. begin
  85.  
  86.   if not OpenStdDev(OT, 1) then begin
  87.     WriteLn('Can''t open console device.');
  88.     Halt(1);
  89.     end;
  90.   S1  := string(Ptr(PrefixSeg, $80)^);
  91.   WriteLn(OT, ^M^J^M^J,'':8,'The command tail is');
  92.   WriteLn(OT, '':8, S1);
  93.   WriteLn(OT, '':8,'MaxAvail = ',MaxAvail);
  94.   WriteLn(OT, '':8,'MemAvail = ',MemAvail);
  95.   WriteLn(OT);
  96.   ClInit;
  97.   ClParse(Nil, false, [';', '-']+[ReadSwCh], [':', '='], Err);
  98.   WriteLn(OT, '':10, 'Error return = ', Err);
  99.   if ExistFile('DoPop') then
  100.     while PopSwitch(Y) do begin
  101.       WriteLn(OT, '':10, 'Name = ', Y.Name);
  102.       WriteLn(OT, '':10, 'Value type = ', VT[Y.SwVal]);
  103.       WriteLn(OT, '':10, 'Switch Value = ', ValStr);
  104.       WriteLn(OT, '':10, 'MaxAvail = ',MaxAvail);
  105.       WriteLn(OT, '':10, 'MemAvail = ',MemAvail);
  106.       WriteLn(OT);
  107.       AnyKey;
  108.       end {while}
  109.   else begin
  110.     while GetSwitch(Y) do begin
  111.       WriteLn(OT, '':10, 'Name = ', Y.Name);
  112.       WriteLn(OT, '':10, 'Value type = ', VT[Y.SwVal]);
  113.       WriteLn(OT, '':10, 'Switch Value = ', ValStr);
  114.       WriteLn(OT, '':10, 'MaxAvail = ',MaxAvail);
  115.       WriteLn(OT, '':10, 'MemAvail = ',MemAvail);
  116.       WriteLn(OT);
  117.       AnyKey;
  118.       end; {while}
  119.     ClClose;
  120.     end; {else}
  121.   WriteLn(OT, '':8, 'Final memory values:');
  122.   WriteLn(OT, '':10,'MaxAvail = ',MaxAvail);
  123.   WriteLn(OT, '':10,'MemAvail = ',MemAvail);
  124.   if Err <> 0 then begin
  125.     WriteLn(OT);
  126.       AnyKey;
  127.     end;
  128.   Flush(OT);
  129.   end.
  130.